(function() {
    var myApp = angular.module('myApp');

    //角色列表
    myApp.constant("myRoleTableOption", {
        dom        : 'trip',
        processing : true,
        serverSide : true,
        deferRender: true,
        scrollX    : false,
        scrollY    : '100%',
        scroller   : true,
        select     : 'single',
        ordering   : false,
        searchDelay: 1000,
        language   : { url: '../../pub/datatables/zh_cn.json' },
        columns    : [
            { data: 'name'   },
            { data: 'descr'  },
            {
                data: 'status',
                render : function ( data, type, row, meta ) {
                    return data == 1 ? '启用' : '禁用';
                }
            },
            {
                render : function ( data, type, row, meta ) {
                    var src = "";
                    src += '<span  style="cursor:pointer;margin-right:15px;margin-left:15px;" ng-click="showeditmodal('+meta.row+') " ><img src="edit.png"></span>';
                    src += '<span  style="cursor:pointer;margin-right:15px;" ng-click="deleterolemodal('+meta.row+') " ><img src="remove.png"></span>';
                    return src;
                }
            },
            {
                render : function ( data, type, row, meta ) {
                    var str='';
                    str+='<a class="btn btn-primary btn-sm " ng-click="setMenus(\'' + row.role_id + '\',\'' + row.name + '\')" >设置菜单</a>';
                    str+= '<a style="margin-left:8px;" class="btn btn-primary btn-sm " ng-click="setUsers(\'' + row.role_id + '\',\'' + row.name + '\')" >设置用户</a>';
                    return str;
                }
            }
        ]
    });

    //设置角色用户
    myApp.constant("myUserTableOption", {
        dom        : 'trip',
        ordering : false,
        processing : true,
        serverSide : true,
        deferRender: true,
        scrollY    : '100%',
        paging     : true,
        scroller   : true,
        order      : [[0, 'desc']],
        searchDelay: 1000,
        pageLength : 1000,
        language   : { url: '../../pub/datatables/zh_cn.json' },
        columns    : [
            {
                searchable: false,
                render : function ( data, type, row, meta ) {
                    if(row.selected==1){
                        return '<input type="checkbox" checked="checked" style="height: 15px;width: 15px;" >'
                    }else{
                        return '<input type="checkbox"  style="height: 15px;width: 15px;" >'
                    }
                }
            },
            { data: 'cellphone_mail' 	},
            { data: 'user_name' },
            { data: 'email' },
            { data: 'cellphone' },
            {
                data: 'active_status',
                render : function ( data, type, row, meta ) {
                    return data == 'Y' ? '启用' : '禁用';
                }
            }
        ]
    });

    //设置角色权限
    myApp.constant("myPermissionTableOption", {
        dom        : 'ftir',
        processing : true,
        serverSide : true,
        deferRender: true,
        scrollY    : '100%',
        scroller   : true,
        select     : true,
        searchDelay: 1000,
        order      : [[0, 'desc']],
        language   : { url: '../../pub/datatables/zh_cn.json' },
        columns    : [
            { data: 'name'},
            { data: 'descr'   },
            {
                data: 'status',
                render : function ( data, type, row, meta ) {
                    return data == 1 ? '启用' : '禁用';
                }
            }
        ]
    });

    //添加权限列表
    myApp.constant("selectqxTableOption", {
        dom        : 'ftir',
        processing : true,
        serverSide : true,
        deferRender: true,
        scrollY    : '100%',
        scroller   : true,
        select     : true,
        searchDelay: 1000,
        order      : [[0, 'desc']],
        language   : { url: '../../pub/datatables/zh_cn.json' },
        columns    : [
            {
               
                    data: 'selected',
                    searchable: false,
                    className: 'select-checkbox',
                    render : function ( data, type, row, meta ) {
                        return '';
                    }
            },
            { data: 'name'},
            { data: 'descr'   },
            {
                data: 'status',
                render : function ( data, type, row, meta ) {
                    return data == 1 ? '启用' : '禁用';
                }
            }
        ]
    });


    //设置角色用户列表
    myApp.constant("myRoleUserListTableOption", {
        dom        : 'ftir',
        processing : true,
        serverSide : true,
        deferRender: true,
        scrollY    : '100%',
        paging     : true,
        scroller   : true,
        select     : true,
        order      : [[0, 'desc']],
        searchDelay: 1000,
        pageLength : 1000,
        language   : { url: '../../pub/datatables/zh_cn.json' },
        columns    : [
            { data: 'username'  },
            { data: 'cname' },
            { data: 'email' },
            { data: 'telephone' },
            {
                data: 'status',
                render : function ( data, type, row, meta ) {
                    return data == 1 ? '启用' : '禁用';
                }
            }
        ]
    });

    // 选中用户
    myApp.constant("selectUserTableOption", {
        dom        : 'ftir',
        processing : true,
        serverSide : true,
        deferRender: true,
        scrollY    : '100%',
        paging     : true,
        scroller   : true,
        select     : true,
        order      : [[1, 'desc']],
        searchDelay: 1000,
        pageLength : 1000,
        language   : { url: '../../pub/datatables/zh_cn.json' },
        columns    : [
            {
                data: 'selected',
                searchable: false,
                className: 'select-checkbox',
                render : function ( data, type, row, meta ) {
                    return '';
                }
            },
            { data: 'username'  },
            { data: 'cname' },
            { data: 'email' },
            { data: 'telephone' },
            {
                data: 'status',
                render : function ( data, type, row, meta ) {
                    return data == 1 ? '启用' : '禁用';
                }
            }
        ]
    });

})();


